#include<iostream>
using namespace std;
string s1, s2;
int l1,l2,r1,r2,n;
void dfs(int l1, int r1, int l2, int r2)
{
	if (l1 > r1) return;
	cout << s2[r2];
	int p = l1;
	while (s1[p] != s2[r2]) p++;
	dfs(l1,p - 1,l2,l2 + p - l1 - 1);
	dfs(p + 1, r1, l2 + p - l1, r2 - 1);
} 
int main()
{
	cin >> s1 >> s2;
	dfs(l1, s1.size() - 1, l2, s2.size() - 1);
	return 0;
}